;   AutoHotKey v2.0.10

Run "lib\lib.ahk"
IniFile     := "config\config.ini"
senss       := GetIniValue(IniFile, "Settings", "sens")
zoomsenss   := GetIniValue(IniFile, "Settings", "zoomsens")
M4A4        := GetIniValue(IniFile, "KeyBinds", "M4A4")
AUG         := GetIniValue(IniFile, "KeyBinds", "AUG")
SG          := GetIniValue(IniFile, "KeyBinds", "SG")
Galil       := GetIniValue(IniFile, "KeyBinds", "Galil")
M4A1        := GetIniValue(IniFile, "KeyBinds", "M4A1")
AK          := GetIniValue(IniFile, "KeyBinds", "AK")
UMP         := GetIniValue(IniFile, "KeyBinds", "UMP")
Zoom        := GetIniValue(IniFile, "KeyBinds", "Zoom")
Famas       := GetIniValue(IniFile, "KeyBinds", "Famas")
Off         := GetIniValue(IniFile, "KeyBinds", "Off")

MyGui := Gui(, "AHK CS2 压枪脚本")
MyGui.SetFont("S12 CGreen Bold", "微软雅黑")
MyGui.Add("Text", "x2 y-1 w480 h20 Center", "AutoHotKey 压枪 CS2")
MyGui.SetFont("S8 CBlack Bold", "微软雅黑")
MyGui.Add("Tab3","x2 y19 w480 h390", ["按键绑定"])

MyGui.Add("GroupBox", "x2 y59 w110 h60", "M4A4(CT)")
MyGui.Add("GroupBox", "x182 y59 w110 h60", "M4A1-S(CT)")
MyGui.Add("GroupBox", "x362 y59 w110 h60", "Famas(CT)")
MyGui.Add("GroupBox", "x2 y129 w110 h60", "AUG(CT)")
MyGui.Add("GroupBox", "x182 y129 w110 h60", "AK-47(T)")
MyGui.Add("GroupBox", "x362 y129 w110 h60", "Galil AR(T)")
MyGui.Add("GroupBox", "x2 y199 w110 h60", "SG 553(T)")
MyGui.Add("GroupBox", "x182 y199 w110 h60", "UMP-45")
MyGui.Add("GroupBox", "x362 y199 w110 h60", "暂停/运行")
MyGui.Add("GroupBox", "x2 y269 w110 h60 CRed", "zoomsens")
MyGui.Add("GroupBox", "x182 y269 w110 h60 CRed", "sens")
MyGui.Add("GroupBox", "x362 y269 w110 h60", "hold zoom")

MyGui.Add("Hotkey", "x12 y79 w90 h30", M4A4)
MyGui.Add("Hotkey", "x12 y149 w90 h30", AUG)
MyGui.Add("Hotkey", "x12 y219 w90 h30", SG)
MyGui.Add("Hotkey", "x192 y79 w90 h30", M4A1)
MyGui.Add("Hotkey", "x192 y149 w90 h30", AK)
MyGui.Add("Hotkey", "x192 y219 w90 h30", UMP)
MyGui.Add("Hotkey", "x372 y79 w90 h30", Famas)
MyGui.Add("Hotkey", "x372 y149 w90 h30", Galil)
MyGui.Add("Hotkey", "x372 y219 w90 h30", Off)
MyGui.Add("Hotkey", "x372 y289 w90 h30", zoom)

MyGui.Add("Edit", "x12 y289 w90 h30", zoomsenss)
MyGui.Add("Edit", "x192 y289 w90 h30", senss)

MyGui.SetFont("S10 CBlack", "微软雅黑")
MyGui.Add("Text", "x42 y359 w390 h20 Center", "您可以随意改变后坐力武器的按键")
MyGui.Add("Text", "x42 y339 w390 h20 CRed Center", "重要：设置您的游戏灵敏度")
MyGui.Add("Picture", "x412 y339 w60 h60", "img\cs2.png")
MyGui.Add("Button", "x182 y379 w110 h20", "保存").OnEvent("Click", GenerateConfig)

MyGui.Show("x599 y260 h417 w489")

GenerateConfig(*)
{
    MyGui.Submit(false)
    IniFile := "config\config.ini"
    FileDelete IniFile
    FileAppend "[Settings]`nsens=%senss%`nzoomsens=%zoomsenss%`n", IniFile
    FileAppend "[KeyBinds]`nM4A4=%M4A4%`nAUG=%AUG%`nSG=%SG%`nGalil=%Galil%`nM4A1=%M4A1%`nAK=%AK%`nUMP=%UMP%`nZoom=%zoom%`nFamas=%Famas%`nOff=%off%`n", IniFile
    MsgBox "Settings have been saved!"
}

GetIniValue(file, section, key) 
{
    Value := IniRead(file, section, key)
    return Value
}